<?php

class Model
{
    # setup singleton
    protected static $_database;

    # reference to database connection instance
    protected $Db;


    public function __construct()
    {
        if (!self::$_database) {
            self::$_database = new Database();
        }
        $this->Db =& self::$_database;
    }

    public function __destruct()
    {
        $this->Db->disconnect();
    }

    public function getDb()
    {
        return $this->Db;
    }
}